﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>资源池客户管理</title>
    <#--要在script前引入-->
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $('.btn-input').click(function () {

                //清除模态框中表单里的旧有数据
                $('#editForm')[0].reset();
                $('input[name="id"]').val('')
                //设置标题
                $('.modal-title').html('潜在客户新增');

                var data = $(this).data('json');
                console.log(this);
                if(data){
                    $('.modal-title').html('潜在客户编辑');
                    $('input[name=id]').val(data.id);
                    $('input[name=name]').val(data.name);
                    $('input[name=age]').val(data.age);
                    $('select[name=gender]').val(data.gender);
                    $('input[name=tel]').val(data.tel);
                    $('input[name=qq]').val(data.qq);
                    $('select[name="job.id"]').val(data.job.id);
                    $('select[name="source.id"]').val(data.source.id);
                    $('select[name="seller.id"]').val(data.seller.id);
                }


                $('#editModal').modal('show');
            });


            $('.btn-submit').click(function () {
                $('#editForm').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });

            $('.btn-trace').click(function () {

                var data = $(this).data('json');
                console.log(this);
                if(data){
                    $('input[name="customer.id"]').val(data.id);
                    $('input[name=name]').val(data.name);
                }

                $('#traceModal').modal("show");
            });



            $('.btn-status').click(function () {
                var data = $(this).data('json');
                console.log(data);
                if(data){
                    $('input[name="customerId"]').val(data.id);
                    $('input[name=customerName]').val(data.name);
                }
                $('#statusModal').modal('show');
            });

            $('.statusSubmit').click(function () {
                $('#statusForm').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });

            $('.btn-transfer').click(function () {

                var data = $(this).data('json');
                if(data){
                    $('input[name="customer.id"]').val(data.id);
                    $('input[name="customer.name"]').val(data.name);
                    $('input[name="oldSeller.id"]').val(data.sellerId);
                    $('input[name="oldSeller.name"]').val(data.sellerName);


                }
                $('#transferModal').modal('show')
            });

            $('.transferSubmit').click(function () {
                $('#transferForm').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });

            $('.btn-transfer1').click(function () {

                var data = $(this).data('json');
                if(data){
                    $('input[name="customer.id"]').val(data.id);
                    $('input[name="customer.name"]').val(data.name);
                    $('input[name="oldSeller.id"]').val(data.sellerId);
                    $('input[name="oldSeller.name"]').val(data.sellerName);

                }
                $('#transferModal1').modal('show')
            });

            $('.transferSubmit1').click(function () {
                $('#transferForm1').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });


        })
    </script>


</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu = "customer_pool">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>客户资源池</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/customer/poolList" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">

                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入姓名/手机">
                    </div>
                    <@shiro.hasAnyRoles name="admin,Market_Manager">
                        <div class="form-group">
                            <label for="dept"> 销售人:</label>
                            <select class="form-control" name="sellerId" >
                                <option value="-1">全部人</option>
                           <#list sellers as seller>
                                <option value="${seller.id}" <#if seller.id==qo.sellerId>selected</#if>>${seller.name}</option>
                            </#list>
                            </select>
                        <#--<%--<script>
                            $("#dept option[value='${qo.deptId}']").prop("selected", true);
                        </script>--%>-->
                        </div>
                    </@shiro.hasAnyRoles>
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>


                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
<@shiro.hasAnyRoles name="Market,Market_Manager">
                <table class="table table-hover table-bordered">
                        <tr>
                            <th>名称</th>
                            <th>年龄</th>
                            <th>性别</th>
                            <th>电话</th>
                            <th>QQ</th>
                            <th>工作</th>
                            <th>来源</th>
                            <th>销售人</th>
                            <th>状态</th>
                            <#--<th>转正时间</th>-->
                       <#--<@shiro.hasAnyRoles name="Market,Market_Manager">-->
                            <th>操作</th>
                        <#--</@shiro.hasAnyRoles>-->
                        </tr>
                        <#list pageInfo.list as customer>
                            <tr>
                                <td>${customer.name}</td>
                                <td>${customer.age}</td>
                                <td>${customer.genderName}</td>
                                <td>${customer.tel}</td>
                                <td>${customer.qq}</td>
                                <td>${customer.job.title}</td>
                                <td>${customer.source.title}</td>
                                <td>${customer.seller.name}</td>
                                <td>${customer.statusName}</td>
                                <#--<td>${customer.positiveTime}</td>-->
                            <#--<@shiro.hasAnyRoles name="Market,Market_Manager">-->
                                <td>
                                    <a data-json='${customer.jsonData}' class="btn btn-warning btn-xs btn-transfer">
                                        <span class="glyphicon glyphicon-pencil"></span> 吸纳
                                    </a>
                                    <a data-json='${customer.jsonData}' class="btn btn-danger btn-xs btn-transfer1">
                                        <span class="glyphicon glyphicon-share-alt"></span> 移交
                                    </a>

                                </td>
                            <#--</@shiro.hasAnyRoles>-->
                            </tr>
                        </#list>
                    </table>
</@shiro.hasAnyRoles>
                    <!--分页-->
                <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>








<#--移交模态框-->
<div id="transferModal" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">客户吸纳</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTransfer/yijiao" method="post" id="transferForm" style="margin: -3px 118px">
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">客户姓名：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="customer.name"   readonly >
                            <input type="hidden" class="form-control"  name="customer.id"  >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">旧营销人员：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="oldSeller.name" readonly >
                            <input type="hidden" class="form-control"    name="oldSeller.id"  >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">新营销人员：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="newSeller.name" value="${employee.name}" readonly >
                            <input type="hidden" class="form-control"  name="newSeller.id" value="${employee.id}" >
                            <#--<select name="newSeller.id" id="newSeller" class="form-control">
                            <#list sellers as seller>
                                <option value="${seller.id}">${seller.name}</option>
                            </#list>
                            </select>-->
                        </div>
                        <input type="hidden"    name="status"  >
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">移交原因：</label>
                        <div class="col-sm-8">
                            <textarea type="text" class="form-control" id="transReason" name="transReason" cols="10" ></textarea>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary transferSubmit" >保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div id="transferModal1" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">客户移交</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTransfer/yijiao" method="post" id="transferForm1" style="margin: -3px 118px">
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">客户姓名：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="customer.name"   readonly >
                            <input type="hidden" class="form-control"  name="customer.id"  >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">旧营销人员：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="oldSeller.name" readonly >
                            <input type="hidden" class="form-control"    name="oldSeller.id"  >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">新营销人员：</label>
                        <div class="col-sm-8">
                            <select name="newSeller.id" id="newSeller" class="form-control">
                            <#list sellers as seller>
                                <option value="${seller.id}">${seller.name}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">移交原因：</label>
                        <div class="col-sm-8">
                            <textarea type="text" class="form-control" id="transReason" name="transReason" cols="10" ></textarea>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary transferSubmit1" >保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
